<?php echo $this->Html->script(array('admin/multiSelect','default/address','default/order'))?>
<?php echo $this->Form->create('UserOrder',array('onsubmit'=>'false'))?>
<div class="content">
	<div class="buzhou bg02">	
         	<ul>
            	<li class="my01">我的购物车</li>
                <li class="my02">订单信息</li>
                <li class="my03">确认支付</li>
            </ul>
	</div>
   	<div class="clear"></div>
    <div class="tianxie">
    	<h3>确认订单信息</h3>
        	<table width="100%" border="0" cellspacing="0" cellpadding="0" class="queren">
              <thead>	
                  <tr>
                    <td width="57%" height="30" style="text-indent:30px;">商品名称</td>
                    <td width="11%" height="30" align="center">座位</td>
                    <td width="11%" height="30" align="center">单价</td>
                    <td width="11%" height="30" align="center">数量</td>
                    <td width="10%" height="30" align="center">合计</td>
                  </tr>
              </thead>
              <tbody>
              	<?php echo $this->Form->hidden('seat',array('value'=>true))?>
              	<?php $i=-1;foreach ($carts['data'] as $item):$i++;?>
                  <tr>
                    <td height="40" style="text-indent:30px;">
                    	<?php 
                    		echo $title = $item['object']['Ticket']['title'];
							echo '<br/><font style=margin-left:30px>开始时间：'.$item['object']['TicketShowing']['showtime'].'</font>';
							echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][title]",'type'=>'hidden','value'=>$item['param']['title']));
							echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][ticket_id]",'type'=>'hidden','value'=>$item['object']['Ticket']['id']));
							echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][ticket_price_id]",'type'=>'hidden','value'=>0));
							echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][ticket_showing_id]",'type'=>'hidden','value'=>$item['param']['ticket_showing_id']));
							echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][ticket_seat_id]",'type'=>'hidden','value'=>$item['param']['seat_id']));
							echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][ticket_seat_sold_id]",'type'=>'hidden','value'=>1));
							echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][price_num]",'type'=>'hidden','value'=>$item['count']));
                    	?>
                    	
                    </td>
                    <td height="30" align="center">
                    	<?php echo $item['title']?>
                    	<?php 
                    	echo $this->Form->input('',array('name'=>"data[UserOrderList][$i][spt_eticket]",'class'=>'pluslogistic','type'=>'hidden','value'=>0));
                    	?>
                    </td>
                    <td height="30" align="center">
                    	<?php 
                    		$pricedel = ($item['param']==1)?'del_line':'';
                    		$epricedel = ($item['param']!=1)?'del_line':'';
                    	?>
                    	<span class = '<?php echo $pricedel?>'>　¥<?php echo $item['price']?>　</span>
                    </td>
                    <td height="30" align="center"><?php echo $item['count']?></td>
                    <td height="30" align="center">¥<?php echo ($item['param']==1?$item['eprice']:$item['price'])*$item['count']?></td>
                  </tr>
                 <?php endforeach;?>
              </tbody>
            </table>
        </div>
        
         <div id = 'ps' class="tianxie">
         	<h3>配送方式</h3>
         	<?php echo $this->Form->input('sys_gettype_id',array('type'=>'radio','legend'=>false,'default'=>1,'options'=>$sysGettypes))?>
        </div>
        <div id = 'smqh' class="tianxie smqh" style = 'display:none'>
         	<h3>上门取货地址</h3>
            <div class="input radio required">
            	<ul class="added">
	                <li>
						<span>联系人:</span>
                        <?php echo $this->Form->input('UserOrder.address_receive',array('div'=>false,'label'=>false,'class'=>"txt"))?>
                        您的姓名
	                </li>
	                <li>
						<span>联系电话:</span>
	                    <?php echo $this->Form->input('UserOrder.address_phone',array('div'=>false,'label'=>false,'class'=>"txt"))?>
	                        您的手机号码，方便我们与您联系
					</li>
					<li style = 'line-height: 28px;'>
						<span>取票地址:</span>
						西安市丈八一路一号汇鑫大厦A6层
					</li>
					<li style = 'line-height: 28px;'>
						<span>联系电话:</span>
						400-803-6533
					</li>
	            </ul>
            </div>
        </div>
    	<div id = 'js' class="tianxie">
         	<h3>寄送至已存地址</h3>
         	<ol id = 'u_a_l'>
         	<?php if(!empty($address)):?>
         	<?php foreach ($address as $ua):?>
            <li id=<?php echo 'item-'.$ua['UserAddress']['id']?>>
            	<label>
            	<?php echo $this->Form->input('address_id',array('type'=>'radio','options'=>array($ua['UserAddress']['id']=>''),'label'=>false,'div'=>false,'hiddenField'=>false))?>
            		<?php
                    			 echo $ua['UserAddress']['receiver'];
                    			 echo '　'.sex($ua['UserAddress']['sex']);
                    			 echo '　'.$ua['SysProvince']['name'];
                    			 echo '　'.$ua['SysCity']['name'];
                    			 echo '　'.$ua['UserAddress']['address'];
                    		?>
                 </label>
            </li>
            <?php endforeach;?>
            <?php endif;?>
            </ol>
            <label>
            	<?php echo $this->Form->input('address_id',array('type'=>'radio','options'=>array(0=>''),'label'=>false,'div'=>false,'hiddenField'=>false))?>
            	使用其他地址
            </label>
            <ul class="added" id = 'new_address' <?php if(!empty($address)){echo 'style=display:none';}?>>
            	<span class="jtimg"></span>
            	<li>
                	<span>收货地址:</span>
                    <?php echo $this->Form->input('UserAddress.sys_province_id',array('options'=>$sysProvinces,'div'=>false,'label'=>false,'id'=>'f_cate','default'=>784))?>
                    <?php echo $this->Form->input('UserAddress.sys_city_id',array('options'=>$sysCitys,'div'=>false,'label'=>false,'id'=>'s_cate'))?>
                    <?php echo $this->Form->input('UserAddress.type',array('value'=>'order','label'=>false,'type'=>"hidden"))?>
                    <?php echo $this->Form->input('UserAddress.sys_area_id',array('value'=>139,'label'=>false,'type'=>"hidden"))?>
                </li>
                <li>
                    <span>详情地址:</span>
                    <?php echo $this->Form->input('UserAddress.address',array('div'=>false,'label'=>false,'class'=>"txt","style"=>"width:410px;"))?>
                </li>
                <li>
                        <span>收货人:</span>
                        <?php echo $this->Form->input('UserAddress.receiver',array('div'=>false,'label'=>false,'class'=>"txt"))?>
                        您的收货姓名
                    </li>
                <li>
                    <span>性别:</span>
					<?php echo $this->Form->input('UserAddress.sex',array('div'=>false,'default'=>1,'options'=>sex(),'type'=>'radio','legend'=>false))?>
				</li>
                <li>
					<span>手机:</span>
                    <?php echo $this->Form->input('UserAddress.cellphone',array('div'=>false,'label'=>false,'class'=>"txt"))?>
                        您的手机号码，方便收货人与您联系
				</li>
                <li><input onclick="ad.esubmit()" type="button" value="保存" class="btnTj" /></li>
            </ul>
        </div>
        <div class="tianxie">
         	<h3>付款方式</h3>
         	<?php echo $this->Form->input('sys_paytype_id',array('value'=>1,'label'=>false,'type'=>"hidden"))?>
         	<div id = 'pay-type-select'>
         		<ul class="fkfs">
         			<?php 
		         	foreach ($sysPaytypes as $sgt){
						echo "<li class = 'handel' data-id = '{$sgt['SysPaytype']['id']}' style = 'width: 200px;float: left;'>";
						echo "{$sgt['SysPaytype']['title']}";
						echo "</li>";
		         	}
		         	?>
         		</ul>
         		<div class="clear"></div>
         		<?php 
		         	foreach ($sysPaytypes as $sgt){
						echo "<div class = 'ptc uop-{$sgt['SysPaytype']['id']}' style = 'display:none'>";
								foreach ($sgt['UserOrderPaytype'] as $uop){
									if($uop['content'] != ''){
										$title_ext = ' ('.$uop['content'].') ';
									}else{
										$title_ext = '';
									}
									echo $this->Form->input('user_order_paytype_id',array('options'=>array($uop['id']=>$uop['title'].$title_ext),'type'=>"radio",'hiddenField'=>false));
								}
						echo "</div>";
		         	}
		        ?>
         	</div>
         	
        </div>
       
        <div class="tianxie" style = 'padding-bottom:0'>
         	<h3>
         		<input id = 'need_title' name="data[UserOrder][need_title]" type="checkbox" value="1" />
         		我要开发票
         	</h3>
            <ul id = 'needtitle' class="txList" style = 'display:none'>
                <li class="fapiao">发票抬头：
                	<?php echo $this->Form->input('title',array('div'=>false,'label'=>false,'class'=>'txt'))?>
                </li>
                <li class="sming">不填写为个人发票，发票内容只能为票款</li>
            </ul>
        </div>    
        <div class="tianxie">
         	<h3>其他信息</h3>
            <ul class="txList">
            	<li style = 'display:none'><em>使用余额</em><input name="" type="text" class="txt" style="width:150px;"/>余额4600.00</li>
                <li style = 'display:none'><em>使用积分</em><input name="" type="text" class="txt" style="width:150px;" />您当前的可用积分为:1000 积分，本订单最多可以使用300 积分</li>
                <li><em>订单附言</em><textarea name="data[UserOrder][remark]" cols="" rows=""></textarea></li>
            </ul>
         </div>
          <ul class="money floatr">
          	<li style = 'display:none'>
                <span>您将获得：</span> 
                <em>680积分</em>
            </li>
            <li>
                <span>商品总价：</span>
                <em id = 'order_ticket_price' data-price = "<?php echo ($carts['price'])?>">¥<?php echo ($carts['price'])?></em>
            </li>
            <li>
                <span>物流费用：</span>
                <em>¥<font id = 'logistic'>0</font></em>
            </li>
            <li>
                <span>减免：</span>
                <em>- ¥<font id = 'delogistic'>0</font></em>
            </li>
            <li style = 'display:none'>
                <span>使用积分：</span>
                <em>- ¥680.0</em>
            </li>
            <li class="yingfu">
                <span>应付金额：</span>
                <em>¥<font id = 'all_price'><?php echo number_format($carts['price'],1)?></font></em>
            </li>
        </ul> 
        <div class="clear"></div>
        <div class="tijiao">
        	<span>
        		<a href="javascript:;" onclick = 'od.submit()'>提交订单</a>
        	</span>
        </div>   
    </div>	
    <?php echo $this->Form->end();?>
<script>
	$(function(){
		if($('#u_a_l input:first').length>0){
			$('#u_a_l input:first').click();
		}else{
			$('#UserOrderAddressId0').click();
		}
		$('#pay-type-select .uop-1').show();
		$('#UserOrderAddressId0').change(function(){
			var tar = $('#new_address');
			if($(this).is(':checked')){
				tar.show();	
			}else{
				tar.hide();
			}
		});
		od.paytypeEvent();
		od.needtitle();
		jQuery('#UserOrderUserOrderPaytypeId1').click();
		ms.uniform = false;
		var action = jQuery('base').attr('href')+'areas/Areas/getSonOption';
		ms.ready(2,action);

		od.gettype();
	})
</script>